<template>
  <div>
  <el-timeline style="max-width: 600px">
    <el-timeline-item
        v-for="(activity, index) in activities.data"
    :key="index"
    :color="activity.color"
    :timestamp="activity.timestamp"
    >
    {{ activity.content }}
    </el-timeline-item>
  </el-timeline>
  </div>
</template>

<script  setup>
import {ref,onMounted,h} from "vue";
import {getProcess} from "@/api/work/process";
import {getInfo} from "@/api/login";
import { useRouter } from "vue-router";

const router = useRouter();
const id = ref(0);
const token = localStorage.getItem('token'); // 从本地存储获取token

onMounted(async () => {
  try {
    const response = await getInfo(token);
    if (response.code === 200) {
      id.value = response.data.userId; // 获取userId
      function selectOne(){
        getProcess(id.value).then((res) => {
          if (res.status == 200){
            activities.value = res.data
          }
          // console.log(res.data)
          // console.log(activities.value)
          // activities.value.data.forEach(activity => {
          //   console.log(activity.content);
          // });

        })
      }
      selectOne()
    }
  } catch (error) {
    console.error('获取用户信息失败', error);
  }
});

const activities = ref(
  []
)
</script>
